var api = require('../../../../api.js');
var utils = require('../../../../utils.js');
// var WxParse = require('../../wxParse/wxParse.js');
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        banner: [
            {
                "name": 'banner_02',
                "img": "/images/tequan.png"
            }
        ],
       
    },
    // 打电话
    makephone:function(e){
        let that = this;
        wx.makePhoneCall({
            phoneNumber: that.data.sotre.contact_tel
        })
    },
    // 
    to_activity:function(e){
        console.log(e);
      let type_id = e.currentTarget.dataset.typeid ? e.currentTarget.dataset.typeid : 0;//分类id
      let id = e.currentTarget.dataset.id ? e.currentTarget.dataset.id : 0;//活动id
        wx.navigateTo({
          url: '/page/casa/pages/activity_detail/activity_detail?id=' + id + '&typeid=' + type_id,
            success: function(res) {},
            fail: function(res) {},
            complete: function(res) {},
        })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        var menu = wx.getStorageSync("casa_navbar");
        menu.navs[1].active = true;
        menu.navs[2].active = false;
        that.setData({
            _navbar: menu
        })

        app.request({
            url: api.casa.topic_type ,
            method: 'GET',
            success: function(res) {
                console.log(res)
                that.setData({
                    navlist: res.data.topic_type,
                    activitylist: res.data.activitylist,
                })
            },
            fail: function(res) {},
            complete: function(res) {},
        })

         

    //   app.request({
    //         url: api.default.navbar,
    //         success: function (res) {
    //           that.setData({
    //             _navbar: res.data
    //           })
    //         },
    //   })


    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {
        let  that = this;
        wx.getStorage({
            key: 'phoneNum',
            success: function(res) {
                that.setData({
                    sotre:res.data.num
                })
                console.log(res.data.num)
            },
        })
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    }
})